﻿CREATE PROCEDURE [dbo].[AddPerson]
    @PersonId uniqueidentifier,
    @LastName nvarchar(50),
    @FirstName nvarchar(50),
    @MiddleName nvarchar(50),
    @Photo varbinary(max),
	@Email varchar(50),
	@UserType uniqueidentifier,
	@PasswordHash nvarchar(256),
	@PasswordSalt nvarchar(256),
	@Login nchar(40),
	@Comment nvarchar(max),
    @CreatedBy uniqueidentifier,
    @IsDeleted bit,
	@CreatedOn datetime,
    @LastChanged datetime,
	@LastChangedBy uniqueidentifier,

	@TimeStamp timestamp output

AS

	INSERT INTO Person 

	(PersonId, LastName, FirstName, MiddleName, Photo, Email, UserType, PasswordHash, PasswordSalt, [Login], Comment, 
	 CreatedBy, IsDeleted, CreatedOn, LastChanged, LastChangedBy)

	VALUES 

	(@PersonId, @LastName, @FirstName, @MiddleName, @Photo, @Email, @UserType, @PasswordHash, @PasswordSalt, @Login, @Comment, 
	 @CreatedBy, @IsDeleted, @CreatedOn, @LastChanged, @LastChangedBy)

	SELECT @TimeStamp = [TimeStamp]

	FROM Person WHERE PersonId=@PersonId

RETURN 0